﻿// Shader-Based-Image-Processing (SBIP)
// http://code.google.com/p/sbip/
//
// Copyright © Frank Nagl, 2009-2011
// admin@franknagl.de
//
// MeanShift filter copyright © Tobias Bindel, 2011
//
namespace SBIP.Filter
{
    using System;

    /// <summary>Do not use this meansift filter. Still in progress.</summary>
    [Obsolete("Do not use. Still in progress.")]
    public class MeanShift : BaseFilter
    {
        private float colorDistance;
        private int spatialRadius;
        private float minimumShifted;
        private int maximumIteration;

        /// <summary>The minimum iteration shifted value until filter converges.
        /// </summary>
        public float MinimumShifted
        {
            get
            {
                return minimumShifted;
            }
            set
            {
                if (Effect == null)
                {
                    throw new ArgumentException("MinimumShifted" + InitMsg);
                }

                minimumShifted = value;
                Effect.Parameters["MinimumShifted"].SetValue(value);
            }
        }

        /// <summary>The maximum iteration shifted value until filter converges.
        /// </summary>
        public int MaximumIteration
        {
            get
            {
                return maximumIteration;
            }
            set
            {
                if (Effect == null)
                {
                    throw new ArgumentException("MaximumIteration" + InitMsg);
                }

                maximumIteration = value;
                Effect.Parameters["MaximumIteration"].SetValue(value);
            }
        }

        /// <summary>The color distance.</summary>
        public float ColorDistance
        {
            get
            {
                return colorDistance;
            }
            set
            {
                if (Effect == null)
                {
                    throw new ArgumentException("ColorDistance" + InitMsg);
                }

                colorDistance = value;
                Effect.Parameters["ColorDistance"].SetValue(value);
            }
        }

        /// <summary>Tthe spatial radius.</summary>
        public int SpatialRadius
        {
            get
            {
                return spatialRadius;
            }
            set
            {
                if (Effect == null)
                {
                    throw new ArgumentException("SpatialRadius" + InitMsg);
                }

                spatialRadius = value;
                Effect.Parameters["SpatialRadius"].SetValue(value);
            }
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="MeanShift"/> class.
        /// </summary>
        public MeanShift() : base("MeanShift")
        {
            // filter is not real-time capable
            RealtimeCapable = false;
        }

        /// <summary>
        /// Defines, that Sobel edge detector is not colored.
        /// </summary>
        protected override void PostInit()
        {
            base.PostInit();

            MaximumIteration = 8;
            MinimumShifted = 16;

            ColorDistance = 32;
            SpatialRadius = 8;
        }
    }
}
